package com.hutiao.snowhb.entities;

import java.sql.Timestamp;

import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

public class AnalyticsLog {
	
	private static Logger logger = Logger.getLogger(AnalyticsLog.class);
	
	private String uri;
	
	private String param;
	
	private String referer;
	
	private String userAgent;
	
	private Timestamp requestTime;
	
	private Timestamp responseTime;
	
	private int code = HttpServletResponse.SC_OK;
	
	private String result;

	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}

	public String getParam() {
		return param;
	}

	public void setParam(String param) {
		this.param = param;
	}

	public String getReferer() {
		return referer;
	}

	public void setReferer(String referer) {
		this.referer = referer;
	}

	public Timestamp getRequestTime() {
		return requestTime;
	}

	public void setRequestTime(Timestamp requestTime) {
		this.requestTime = requestTime;
	}

	public Timestamp getResponseTime() {
		return responseTime;
	}

	public void setResponseTime(Timestamp responseTime) {
		this.responseTime = responseTime;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}
	
	public String getUserAgent() {
		return userAgent;
	}

	public void setUserAgent(String userAgent) {
		this.userAgent = userAgent;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public void writeLog() {
		String anaLogStr = this.getRequestTime().getTime() + "\t" +		 
			this.getUri() + "\t" + 
			this.getParam() + "\t" + 
			this.getReferer() + "\t" + 
			this.getCode() + "\t" +
			this.getResponseTime().getTime() + "\t" +
			this.getResult() + "\t" +
			this.getUserAgent();
		logger.info(anaLogStr);
	}
}
